package com.yeping.controller;

import com.yeping.domain.ResponseResult;
import com.yeping.domain.dto.AddArticleDto;
import com.yeping.domain.entity.Article;
import com.yeping.service.ArticalService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticalService articleService;
    @PostMapping
    public ResponseResult add(@RequestBody AddArticleDto article){
        return articleService.add(article);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Article article){
        return articleService.updateArticle(article);
    }

    @GetMapping("/articleList")
    public ResponseResult getArticleList(Integer pageNum, Integer pageSize, Long categoryId, String title,String isForum){
        return articleService.articleList(pageNum,pageSize,categoryId,title,isForum);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteArticle(@PathVariable Long id){
        return articleService.deleteArticle(id);
    }

    @PostMapping("/del/batch")
    public ResponseResult delBatchArticle(@RequestBody List<Long> ids){
        return articleService.delBatchUser(ids);
    }
}
